package com.zzx.boot.exception;

import com.zzx.boot.utils.R;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalException {

    @ExceptionHandler(value = {RuntimeException.class})
    public R runTimeException(RuntimeException e){
        System.out.println(e);
        return R.error(e.getMessage(),99);
    }

    @ExceptionHandler(value = {Exception.class})
    public R globalException(Exception e){
        System.out.println(e);
        return R.error(e.getMessage(),999);
    }

}
